package demo06.Example;

//制作巧克力练习
public class ChocolateBoiler {
	private boolean empty;//空的
	private boolean boiled;//煮
	private static ChocolateBoiler uniqueInstance;//巧克力锅
  
	private ChocolateBoiler() {
		empty = true;
		boiled = false;
	}
  
	public static ChocolateBoiler getInstance() {
		if (uniqueInstance == null) {
			System.out.println("独特的巧克力锅炉实例");
			uniqueInstance = new ChocolateBoiler();
		}
		System.out.println("巧克力锅炉返回实例");
		return uniqueInstance;
	}

	public void fill() {
		if (isEmpty()) {
			empty = false;
			boiled = false;
			// 在锅炉里装满牛奶/巧克力混合物。
		}
	}
 
	public void drain() {
		if (!isEmpty() && isBoiled()) {
			// 沥干煮沸的牛奶和巧克力
			empty = true;
		}
	}
 
	public void boil() {
		if (!isEmpty() && !isBoiled()) {
			//把东西煮开
			boiled = true;
		}
	}
  
	public boolean isEmpty() {
		return empty;
	}
 
	public boolean isBoiled() {
		return boiled;
	}

}
